/*
 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

package java.nio.channels;

import java.io.IOException;
import java.io.Closeable;


/**
 * A nexus for I/O operations.
 *
 * <p> A channel represents an open connection to an entity such as a hardware
 * device, a file, a network socket, or a program component that is capable of
 * performing one or more distinct I/O operations, for example reading or
 * writing.
 *
 * <p> A channel is either open or closed.  A channel is open upon creation,
 * and once closed it remains closed.  Once a channel is closed, any attempt to
 * invoke an I/O operation upon it will cause a {@link ClosedChannelException}
 * to be thrown.  Whether or not a channel is open may be tested by invoking
 * its {@link #isOpen isOpen} method.
 *
 * <p> Channels are, in general, intended to be safe for multithreaded access
 * as described in the specifications of the interfaces and classes that extend
 * and implement this interface.
 *
 *
 * @author Mark Reinhold
 * @author JSR-51 Expert Group
 * @since 1.4
 */
// I/O 操作的节点。
// 通道表示与实体（如硬件设备、文件、网络套接字或程序组件）的开放连接，该实体能够执行一个或多个不同的 I/O 操作，例如读取或写入。
// 通道是打开的或关闭的。通道在创建时是打开的，一旦关闭，它就会保持关闭状态。
// 通道关闭后，任何对其调用 I/O 操作的尝试都将导致引发 ClosedChannelException
// 可以通过调用其 isOpen 方法来测试通道是否打开。
// 通常，通道旨在安全地进行多线程访问，如扩展和实现此接口的接口和类的规范中所述。
public interface Channel extends Closeable {

    /**
     * Tells whether or not this channel is open.
     *
     * @return <tt>true</tt> if, and only if, this channel is open
     */
    // 此管道是否处于打开状态
    public boolean isOpen();

    /**
     * Closes this channel.
     *
     * <p> After a channel is closed, any further attempt to invoke I/O
     * operations upon it will cause a {@link ClosedChannelException} to be
     * thrown.
     *
     * <p> If this channel is already closed then invoking this method has no
     * effect.
     *
     * <p> This method may be invoked at any time.  If some other thread has
     * already invoked it, however, then another invocation will block until
     * the first invocation is complete, after which it will return without
     * effect. </p>
     *
     * @throws  IOException  If an I/O error occurs
     */
    // 关闭此管道 在一个管道关闭后，随后的任何调用i/o操作的尝试都会抛出ClosedChannelException
    // 如果调用此方法时，这个管道已经被关闭，那么本次调用不会影响任何东西
    // 这个方法可能在任何时候被调用。
    // 如果一个线程正在调用此方法，那么其他试图调用此方法的线程都将被阻塞，直到调用此方法的线程返回
    public void close() throws IOException;

}
